package com.ssy.lingxi.settle.accounts.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;
import com.ssy.lingxi.dto.model.constant.SettlementHelpEnum;

import java.util.Arrays;

/**
 * 对账单流转操作枚举
 * @author Saske
 * @date 2021/12/10
 * @version 2.0.0
 */
public enum ReconciliationOperationEnum {

    /**
     * 提交账单
     */
    SUBMIT(1, "提交账单"),

    /**
     * 确认不通过
     */
    REJECT(2, "确认不通过"),

    /**
     * 确认
     */
    CONFIRM(3, "确认"),

    /**
     * 提交请款
     */
    SUB_APPLY(4, "提交请款");

    private final Integer code;
    private final String message;

    ReconciliationOperationEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    /**
     * 根据状态枚举值获得状态名称
     * @param code 状态枚举值
     * @return 状态名称
     */
    public static String getNameByCode(Integer code) {
        ReconciliationOperationEnum statusEnum = Arrays.stream(ReconciliationOperationEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
        return statusEnum == null ? SettlementHelpEnum.UNKNOWN.getMessage() : statusEnum.getMessage();
    }
}
